﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace MBS.UserControls.ScreenUserControl
{
    public partial class ScreenList : System.Web.UI.UserControl
    {
        MBSBLC.BLC screenblc = new MBSBLC.BLC();
        
        Dictionary<int,int> dct;

        public delegate void ScreenListHandler(int SelectedValue);
        public event ScreenListHandler ScreenListChanged;
                        
        public static int CinemaID;

        public  static int ScreenID;

        

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                screenblc = new MBSBLC.BLC();
            }
        }

        public void LoadDropDownBox()
        {

            dct = new Dictionary<int, int>();
            dct = screenblc.GetAllScreensForACinema(CinemaID);
           
            
                DropDownList1.DataSource = dct;
                DropDownList1.DataTextField = "Value";
                DropDownList1.DataValueField = "Key";
                DropDownList1.DataBind();
            

           

        }

        public int GetSelectedValue()
        {
            try
            {
                ScreenID = Convert.ToInt32(DropDownList1.SelectedValue);
                return ScreenID;
            }

            catch (Exception ex)
            {
                ScreenID = 1;
                return ScreenID;
            }

        }

        public int DropdownlistSize()
     {
        return DropDownList1.Items.Count;
     }

        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            ScreenListChanged(GetSelectedValue());
            
        }
        
    }
}